<form class="form-horizontal" name="storage_form" ng-submit="do_upsert()">
    <div class="modal-header">
        <a class="close" ng-click="close()">&times;</a>

        <div class="input-prepend input-append">
            <h4>{{ title }}</h4>
        </div>
    </div>
    <div class="modal-body">
        <div class="control-group">
            <label class="control-label">名称:</label>

            <div class="controls">
                <input type="text" required ng-model="storage.name" class="input" ng-pattern="/^\w+$/"/>
            </div>
        </div>
        <!--<div class="control-group">
            <label class="control-label">描述:</label>

            <div class="controls">
                <textarea required ng-model="storage.desc"></textarea>
            </div>
        </div>-->


        <div class="control-group">
            <label class="control-label">数据类型:</label>

            <div class="controls">
                <select class="span2" required ng-model="storage.type">
                    <option value="data">数据</option>
                    <option value="iso">ISO</option>
                </select>
            </div>
        </div>
        <div class="control-group" ng-show="storage.type!='iso'">
            <label class="control-label">类型:</label>

            <div class="controls">
                <select class="span2" ng-required="storage.type!='iso'" ng-model="storage.protocol">
                    <option value="nfs">NFS</option>
                    <option value="iscsi">ISCSI</option>
                    <option value="local">本地</option>
                </select>
            </div>
        </div>
        <div class="control-group" ng-show="storage.type=='iso'">
            <label class="control-label">类型:</label>

            <div class="controls">
                <select class="span2" ng-required="storage.type =='iso'" ng-model="storage.protocol">
                    <option value="nfs">NFS</option>
                    <option value="cifs">CIFS</option>
                </select>
            </div>
        </div>

        <hr ng-hide="!storage.protocol||storage.protocol=='local'"/>

        <div ng-show="storage.protocol=='nfs'">
            <div class="control-group">
                <label class="control-label">主机:</label>

                <div class="controls">
                    <input type="text" ng-required="storage.protocol=='nfs'" ng-model="storage.host" class="input"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">路径:</label>

                <div class="controls">
                    <input type="text" ng-required="storage.protocol=='nfs'" ng-model="storage.path" class="input" />
                    <br>示例: /path/subpath
                </div>
            </div>
        </div>


        <!--<div ng-show="storage.type=='local'">
        <div class="control-group">
          <label class="control-label">大小:</label>
          <div class="controls">
            <input type="text" required ng-model="localsize" class="input"/>
          </div>
        </div>-->
        <div ng-show="storage.protocol=='cifs'">
                <div class="control-group">
                  <label class="control-label">cifs路径:</label>
                  <div class="controls">
                    <input type="text" ng-required="storage.protocol=='cifs'" ng-model="storage.path" class="input">
                      <br>示例: //192.168.10.1/path/subpath
                  </div>
                </div>
            <div class="control-group">
                <label class="control-label">用户名:</label>
                <div class="controls">
                    <input type="text" ng-model="storage.username" class="input"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">密码:</label>
                <div class="controls">
                    <input type="password" ng-model="storage.password" class="input"/>
                </div>
            </div>
        </div>
        <div ng-show="storage.protocol=='iscsi'">
            <div class="control-group">
                <label class="control-label">主机:</label>

                <div class="controls">
                    <input type="text" ng-required="storage.protocol=='iscsi'"  ng-model="storage.host" class="input"/>
                    <button type="button" ng-click="search_iscsi_target();">搜索</button>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">目标:</label>

                <div class="controls">
                    <select ng-options="tr.target for tr in storage.targets"  ng-model="storage.target" ng-disabled="!storage.targets">
                        <option value="">下拉选择target</option>
                    </select>
                </div>
            </div>

            <div class="control-group">
                <label class="control-label">用户登录:</label>
                <div class="controls">
                    <input type="checkbox" ng-model="storage.needuser"/>
                </div>
            </div>

            <div class="control-group">
                <label class="control-label">用户名:</label>
                <div class="controls">
                    <input type="text" ng-required="storage.needuser"  ng-model="storage.username" class="input" ng-disabled="!storage.needuser"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">密码:</label>
                <div class="controls">
                    <input type="password" ng-required="storage.needuser"  ng-model="storage.password" class="input" ng-disabled="!storage.needuser"/>
                </div>
            </div>
        </div>
    <hr/>
    <div class="control-group">
        <label class="control-label">关联集群:</label>

        <div class="controls">
            <select class="span2" required ng-model="storage.cluster" ng-options="c.name for c in clusters">
            </select>
        </div>
    </div>
    </div>
    </div>
    <div class="modal-footer">
        <span style="padding-right: 230px;color: red;" ng-show="error">{{ error }}</span>
        <a data-dismiss="modal" class="btn" ng-click="close()">关闭</a>
        <button type="submit" ng-disabled="!storage_form.$valid||saving"  class="btn btn-primary">保存</button>
    </div>
</form>
